<?php

class Longadmin_Model_User extends Zend_Db_Table
{    
	protected $_name = 'user';


    protected function save($form)
    {       
        $data_form = $form->getValues();

        // password hashing
        if (array_key_exists('password', $data_form) && '' != $data_form['password']) {
            $data_form['password'] = md5($data_form['password']);
        } else {
            unset($data_form['password']);
        }
		$params = array(
						'host' =>'localhost',
						'username' =>'340608',
						'password' =>'20061973',
						'dbname' => '340608'
					);
		$db = Zend_Db::factory('mysqli', $params);
		Zend_Db_Table_Abstract::setDefaultAdapter($db);		
		$data = array('username'=> $data_form['username'],
					'title' => $data_form['title'],
					'email'  => $data_form['email'],		
					'password' => $data_form['password'],
					'role' => $data_form['role']	
		);
		$db->insert($table, $data);
    }

}